//=========================================================================
// Copyright (C) 2024 The C++ Component Model(COMO) Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//=========================================================================

#include <string.h>
#include "../src/math_utils.c"

int main() {
    // 给定整数数组
    //int arr[] = {1, 1, 3, 1, 1, 5, 1, 7, 8, 9, 10, 11, 12, 13, 14, 15};
    long long int arr[] = {1, 1, 3, 1, 1, 5, 1};
    int size = sizeof(arr) / sizeof(arr[0]);

    DataState dataStates[sizeof(arr) / sizeof(arr[0])];

    memset(dataStates, DATA_READY, sizeof(arr) / sizeof(arr[0]));

    // 调用函数找出众数并打印结果
    int candidate = FindMode((Int64*)arr, size, 1, &dataStates[0]);
    if (candidate < 0) {
        printf("FindMode, no candidate\n");
    }
    else {
        printf("FindMode, The candidate of the array is: %lld\n", arr[candidate]);
    }

    candidate = MajorityElement((Int64*)arr, size, 1, &dataStates[0]);
    if (candidate < 0) {
        printf("MajorityElement, no candidate\n");
    }
    else {
        printf("MajorityElement, The candidate of the array is: %lld\n", arr[candidate]);
    }

    return 0;
}
